﻿<vsx.ui:DialogWindow x:Class="Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views.ProjectConfigurationEditorWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:vsx.ui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.10.0"
                     xmlns:local.views="clr-namespace:Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views"
                     xmlns:local.converter="clr-namespace:Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Views.Converters"
                     x:Name="this"
                     Title="Code Analysis Configuration Editor"
                     WindowStartupLocation="CenterOwner"
                     MinHeight="500" Height="500" MinWidth="450" Width="450">
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <CheckBox Name="enableCheckBox" Grid.Row="0" IsChecked="{Binding EnableCodeAnalysis}">Enable Code Analysis</CheckBox>
        <TabControl Grid.Row="1" IsEnabled="{Binding EnableCodeAnalysis}" Margin="5">
            <TabItem Header="General" DataContext="{Binding GenericConfiguration}">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <CheckBox Grid.Row="0" IsChecked="{Binding OverrideEnableSearchGac}" Margin="5">Override 'Search Global Assembly Cache for missing references'</CheckBox>
                    <CheckBox Grid.Row="1" IsChecked="{Binding EnableSearchGac}" IsEnabled="{Binding OverrideEnableSearchGac}" Margin="20,0,0,5">Search Global Assembly Cache for missing references</CheckBox>
                    <CheckBox Grid.Row="2" IsChecked="{Binding OverrideIgnoreGeneratedCode}" Margin="5">Override 'Suppress analysis results against generated code'</CheckBox>
                    <CheckBox Grid.Row="3" IsChecked="{Binding IgnoreGeneratedCode}" IsEnabled="{Binding OverrideIgnoreGeneratedCode}" Margin="20,0,0,5">Suppress analysis results against generated code</CheckBox>
                    <CheckBox Grid.Row="4" IsChecked="{Binding OverrideTimeout}"  Margin="5,10,5,0">Override 'Timeout for analysis deadlock detection'</CheckBox>
                    <Label Grid.Row="5" Margin="20,0,0,0">Timeout for analysis deadlock detection</Label>
                    <StackPanel Grid.Row="6" Orientation="Horizontal" IsEnabled="{Binding OverrideTimeout}" Margin="20,0,0,0">
                        <Slider Minimum="{Binding MinimumTimeout}" Maximum="{Binding MaximumTimeout}" Value="{Binding Timeout}" TickFrequency="30" TickPlacement="TopLeft" Width="250"/>
                        <Label Content="{Binding Timeout}" Margin="5,0"/>
                    </StackPanel>
                    <CheckBox Grid.Row="7" IsChecked="{Binding OverrideRuleSet}"  Margin="5,10,5,0">Override 'Analyze code with RuleSet'</CheckBox>
                    <Label Grid.Row="8" Margin="20,0,0,0">Analyze code with RuleSet</Label>
                    <StackPanel Grid.Row="9" Orientation="Horizontal" IsEnabled="{Binding OverrideRuleSet}" Margin="20,0,0,5">
                        <ComboBox ItemsSource="{Binding RuleSets}" DisplayMemberPath="Name" SelectedValuePath="Path" SelectedValue="{Binding RuleSet}" ToolTip="{Binding SelectedItem.Name, RelativeSource={x:Static RelativeSource.Self}}" Width="210"/>
                        <Button Command="{Binding BrowseRuleSetCommand}" Width="60" Margin="5,0">Browse</Button>
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="Build" DataContext="{Binding BuildConfiguration}">
                <Grid Margin="5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <GroupBox Grid.Row="0" Header="MSBuild Integration" Margin="5">
                        <Grid>
                            <Grid.Resources>
                                <Style x:Key="textBlockStyle" TargetType="TextBlock">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding CanIntegrateMSBuild}" Value="True">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Grid.Resources>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <CheckBox Grid.Row="0" IsChecked="{Binding EnableCodeInspectionOnBuild}" IsEnabled="{Binding CanIntegrateMSBuild}" Margin="5">Enable code inspection on build</CheckBox>
                            <TextBlock Grid.Row="1" Style="{StaticResource textBlockStyle}" TextWrapping="Wrap" Margin="10">
                                You have to install 'FxCop Integrator MSBuild Tasks' to use this feature. Please visit <Hyperlink Command="{Binding ShowProjectSiteCommand}">the FxCop Integrator project site</Hyperlink>.
                            </TextBlock>
                        </Grid>
                    </GroupBox>
                    <GroupBox Grid.Row="1" Header="Obsolete" Margin="5">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <CheckBox Grid.Row="0" IsChecked="{Binding EnableCodeAnalysisOnBuild}" Margin="5">Enable code analysis on build</CheckBox>
                            <TextBlock Grid.Row="1" TextWrapping="Wrap" Foreground="Red" Margin="25,0,5,0">Note that this is the obsolete feature and will be removed in the future release. Please use the 'MSBuild Integration' feature instead.</TextBlock>
                        </Grid>
                    </GroupBox>
                </Grid>
            </TabItem>
            <TabItem Header="Filter" DataContext="{Binding FilterConfiguration}">
                <Grid Margin="5">
                    <Grid.Resources>
                        <local.converter:EnumBooleanConverter x:Key="enumBooleanConverter"/>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <GroupBox Grid.Row="0" Header="Override Mode" Margin="5">
                        <StackPanel>
                            <RadioButton IsChecked="{Binding OverrideFilterPatterns, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Inherit}" Margin="5" ToolTipService.ShowDuration="10000" ToolTip="Inherits filter patterns of the solution configuration or uses the default filter pattterns if the solution configuraiton isn't defined.">Inherit</RadioButton>
                            <RadioButton IsChecked="{Binding OverrideFilterPatterns, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Merge}" Margin="5" ToolTipService.ShowDuration="10000" ToolTip="Merges filter patterns of the solution configuration and below.">Merge</RadioButton>
                            <RadioButton IsChecked="{Binding OverrideFilterPatterns, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Replace}" Margin="5" ToolTipService.ShowDuration="10000" ToolTip="Replaces filter patterns of the solution configuration with below.">Replace</RadioButton>
                        </StackPanel>
                    </GroupBox>
                    <DataGrid Grid.Row="1" ItemsSource="{Binding FilterPatterns}" AutoGenerateColumns="False" HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" Margin="5" CellEditEnding="OnCellEditEnding">
                        <DataGrid.Style>
                            <Style TargetType="DataGrid">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding OverrideFilterPatterns, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Inherit}" Value="True">
                                        <Setter Property="IsEnabled" Value="False"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.Style>
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Value}" Header="Filter Pattern" Width="370"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>
        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Name="saveButton" IsDefault="True" Margin="5" Width="60" Command="{Binding SaveCommand}">Save</Button>
            <Button Name="cacelButton" IsCancel="True" Margin="5" Width="60" Command="{Binding CancelCommand}">Cancel</Button>
        </StackPanel>
    </Grid>
</vsx.ui:DialogWindow>
